# -*- coding: utf-8 -*-

from util import *
import sys

if len(sys.argv) < 2:
    print "usage:de_dup.py src_file"
    exit(-1)
db=opendb()

if db is None:
    print "open db error."
    exit(-1)

group_id = 'WMGD'

cursor = db.cursor()

file = open(sys.argv[1])
for line in file:
    user_id = line.split("/")[-2]
    sql = "insert into group_users (group_id, user_id) values ('%s', '%s') where not exists (select * from group_users where group_id='%s' and user_id='%s') " % (group_id, user_id, group_id, user_id)
    print sql
    # cursor.execute(sql)

file.close()

closedb(db)



